{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "pJ8vZ5q5KZC9"
      },
      "source": [
        "## 1. 安装依赖包 / Installation of dependency packages"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "fJUJLWQ92g6R",
        "outputId": "dec5a9fa-6675-4c4b-fa12-96d384cda294"
      },
      "outputs": [],
      "source": [
        "!pip install accelerate==0.21.0 bitsandbytes==0.40.2 gradio==3.37.0 protobuf==3.20.3 scipy==1.11.1 sentencepiece==0.1.99 transformers==4.31.0"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "27_ipYsZKedX"
      },
      "source": [
        "## 2. 拉取代码 / Pull the code"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "xPWFMkP3F9-5",
        "outputId": "e51e110a-f68c-4d83-e55e-8b23053ca31c"
      },
      "outputs": [],
      "source": [
        "!rm -rf Chinese-Llama-2-7b\n",
        "!git clone https://github.com/LinkSoul-AI/Chinese-Llama-2-7b.git\n",
        "!sed -i 's/launch(server_name=\"0.0.0.0\")/launch(server_name=\"0.0.0.0\", share=True, debug=True, inbrowser=True)/' ./Chinese-Llama-2-7b/example/basic-chat/app.py\n",
        "!sed -i 's/local_files_only=True/local_files_only=False/' ./Chinese-Llama-2-7b/example/basic-chat/model.py\n",
        "!sed -i \"s/model_id = 'LinkSoul\\/Chinese-Llama-2-7b'/model_id = 'LinkSoul\\/Chinese-Llama-2-7b-4bit'/\"  ./Chinese-Llama-2-7b/example/basic-chat/model.py\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mhLG4B6zLcbo"
      },
      "source": [
        "## 3. 下载模型并运行 (耗时) / Download the model and run it (time-consuming)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "e200MmBU2aLT",
        "outputId": "3002a484-9a46-4009-c390-ecb3ecd48ea8"
      },
      "outputs": [],
      "source": [
        "!cd Chinese-Llama-2-7b/example/basic-chat && python app.py"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "toc_visible": true,
      "machine_shape": "hm",
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
